/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#include "StockFilterWidget.h"
#include "StockDayDatabase.h"

namespace QSThink
{
	StockFilterWidget::StockFilterWidget(QWidget *parent)
		: QWidget(parent),_ui(new Ui::StockFilterUI)
	{
		_ui->setupUi(this);

		loadStockBasicInfo();

	}

	StockFilterWidget::~StockFilterWidget()
	{
		delete _ui;
	}

	void StockFilterWidget::loadStockBasicInfo()
	{
		int cnt=StockDayDatabase::getSingleton().getStockCount();
		_ui->tableWidget->setRowCount(cnt);
		for (int i=0;i<cnt;++i)
		{
			StockDayFile* f=StockDayDatabase::getSingleton().getStockDayFile(i);
			QString symbol=f->symbol();
			double price=f->openPriceAverage()/100.0;

			QTableWidgetItem* item0=new QTableWidgetItem(symbol);
			QTableWidgetItem* item3=new QTableWidgetItem(QString::number(price));

			_ui->tableWidget->setItem(i,0,item0);
			_ui->tableWidget->setItem(i,3,item3);

		}
	}

	
}
